package com.burges.net.tableAPIAndSQL.userDefinedDataSource.tableFactory

import java.util

import org.apache.flink.table.factories.StreamTableSourceFactory
import org.apache.flink.table.sources.StreamTableSource
import org.apache.flink.types.Row

/**
  * 创建人    BurgessLee 
  * 创建时间   2020/2/25 
  * 描述     TableFactory定义
  */
class SocketTableSourceFactory extends StreamTableSourceFactory[Row]{
	// 创建SocketTableSOurce示例
	override def createStreamTableSource(properties: util.Map[String, String]): StreamTableSource[Row] = {
		val socketHost = properties.get("connector.host")
		val socketPort = properties.get("connector.port")
		new SocketTableSource(socketHost, socketPort)
	}

	// 指定TableFactory上下文参数
	override def requiredContext(): util.Map[String, String] = {
		val context = new util.HashMap[String, String]()
		context.put("update-mode", "append")
		context.put("connector.type", "dev-system")
		context
	}

	// 指定TableFactory用于处理的参数集合
	override def supportedProperties(): util.List[String] = {
		val properties = new util.ArrayList[String]()
		properties.add("connector.host")
		properties.add("connector.port")
		properties
	}
}
